window.onload=function () {

    var accountRegister = document.getElementById("accountRegister");
    var telphoneRegister = document.getElementById("telphoneRegister");
    var pRegister = document.getElementById("pRegister");
    var aRegister = document.getElementById("aRegister");

    //   进入账号注册的页签
    accountRegister.onmouseover = function () {
        accountRegister.style.backgroundColor="antiquewhite";
        telphoneRegister.style.backgroundColor="white";
        aRegister.style.display = "block";
        pRegister.style.display = "none";
    }

    //进入手机号注册的页签
    telphoneRegister.onmouseover = function () {
        telphoneRegister.style.backgroundColor=" antiquewhite";
        accountRegister.style.backgroundColor="white";
        pRegister.style.display = "block";
        aRegister.style.display = "none";
    }

    //账号注册的表单提交验证
    //得到注册按钮
    var btn01=document.getElementById("btn01");
    btn01.onclick=function () {
        var account=regForm1.account.value;
        var pwd1=regForm1.pwd1.value;
        if (account==""){
            alert("请设置账号");
            regForm1.account.focus();
            return;
        }
        if (pwd1==""){
            alert("请设置密码");
            regForm1.pwd1.focus();
            return;
        }
        //把密码进行加密
        regForm1.pwd1.value =hex_md5(pwd1);

        //提交表单
        regForm1.submit();
    }

    //手机注册的表单提交
    var btn2=document.getElementById("btn2");
    btn2.onclick=function () {
        var phone=regForm2.phone.value;
        var veriCode=regForm2.veriCode.value;
        var pwd2=regForm2.pwd2.value;
        if(phone==""){
            alert("请输入电话号码");
            regForm1.account.focus();
            return;
        }
        if (veriCode==""){
            alert("请输入验证码");
            regForm2.veriCode.focus();
            return;
        }
        if (pwd2==""){
            alert("请设置密码");
            regForm2.pwd2.focus();
            return;
        }
        regForm2.pwd2.value =hex_md5(pwd2);
    }

    //得到验证码
    //得到验证码按钮
    var btn1=document.getElementById("btn1");
    btn1.onclick=function () {
        var phone=regForm2.phone.value;
        //电话号码的正则验证
        if (!(/^1(3|5|7|8)\d{9}$/).test(phone)){
            alert("电话号码格式错误");
            regForm2.phone.focus();
            return;
        } else {
            var url="/javaWeb01/UserPhoneSend?phone="+phone;
            var  req=new XMLHttpRequest();
            req.open("GET",url);
            req.send(null);
            req.onreadystatechange=function () {
                if (req.readyState==4){
                    if (req.status==200 || req.status==304){
                        req.response;
                    }
                }
            }
        }
    }
}